package Sourcecode
import (
	"fmt"
	_ "github.com/go-sql-driver/mysql"
	_"database/sql"
	_"fmt"
	"../model"
	_"reflect"
	_"strconv"
	_"testing"
	dbc "../dataBase"
	"gopkg.in/mgo.v2/bson"
	"gopkg.in/mgo.v2"

)

func Ceshi() {
	a:=dbc.DropCollection()
	if(a!=nil){
		fmt.Print("删除失败",a)
	}else{fmt.Print("删除成功")}
	var qindex=mgo.Index{
		Key:[]string {"questionsID" },
		Unique:true,
	}
	var cindex=mgo.Index{
		Key:[]string {"checkKnowledgePointID" },
		Unique:true,
	}

	//err:=dbc.DropIndex("db","Questions"," QuestionsID")
	err:=dbc.EnsureIndex("db","Questions",qindex)
	if(err==nil){fmt.Print("Questions表添加索引成功")}else {fmt.Print("Questions表添加索引失败",err)}
	er2r:=dbc.EnsureIndex("db","Checkknowledgepoint",cindex)
	if(er2r==nil){fmt.Print("Checkknowledgepoint表添加索引成功")}else {fmt.Print("Checkknowledgepoint表添加索引失败",err)}

	var arr []Model.Questions
	dbc.FindAll("db","indexes",bson.M{},nil,&arr)
	fmt.Print(arr)
	fmt.Printf("共有数据%n",len(arr))
}


